#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * GDI Object Base
 *      Provides a base definition for objects utilizing the GDI API.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
#include "AiObjectBase.h"

using namespace System;
using namespace System::Runtime;;
using namespace System::Runtime::InteropServices;
using namespace Adaptive::Foundation;

namespace Adaptive
{
	namespace Win32
	{
		namespace Gdi
		{
			/// <summary>
			/// Provides a base definition for objects utilizing the GDI API.
			/// </summary>
			public ref class GdiObjectBase abstract : public AiObjectBase
			{
			public:
				/*--------------------------------------------------------------------------------
				 * Constructor / Dispose / Destructor Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Constructor / Dispose / Destructor Methods
				/// <summary>
				/// Class destructor.
				/// </summary>
				~GdiObjectBase();
				#pragma endregion

				/*--------------------------------------------------------------------------------
				 * Public Properties
				 *------------------------------------------------------------------------------*/
				#pragma region Public Properties
				/// <summary>
				/// Gets a value indicating whether the underlying handle is valid.
				/// </summary>
				/// <value>
				/// <b>true</b> if the handle is valid; otherwise, <b>false</b>.
				/// </value>
				property bool IsValid { bool get(); }
				#pragma endregion
	 
				/*--------------------------------------------------------------------------------
				 * Public Methods / Functions
				 *------------------------------------------------------------------------------*/
				#pragma region Public Methods / Functions
				/// <summary>
				/// 
				/// </summary>
				/// <remarks>
				/// 
				/// </remarks>
				void			Attach( IntPtr gdiObjectHandle, bool destroy);
				virtual void	Delete();
				bool			DeleteObject();
				IntPtr			Detach();

				#pragma endregion

			protected:

				/*--------------------------------------------------------------------------------
				 * Constructor / Dispose / Destructor Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Constructor / Dispose / Destructor Methods
				/// <summary>
				/// Initializes a new instance of the class.
				/// </summary>
				/// <param name="objectHandle">An <see cref="IntPtr"/> containing the handle.</param>
				GdiObjectBase(IntPtr objectHandle);
				/// <summary>
				/// Initializes a new instance of the class.
				/// </summary>
				/// <param name="objectHandle">An <see cref="IntPtr"/> containing the handle.</param>
				/// <param name="destroyWhenDone">A value indicating whether to destroy the handle when the instance is disposed.</param>
				GdiObjectBase(IntPtr objectHandle, bool destroyWhenDone);
				/// <summary>	
				/// Initializes a new instance of the class.
				/// </summary>
				/// <param name="objectHandle">An <see cref="HGDIOBJ"/> containing the handle.</param>
				/// <param name="destroyWhenDone">A value indicating whether to destroy the handle when the instance is disposed.</param>
				GdiObjectBase(HGDIOBJ objectHandle, BOOL destroyWhenDone);
				#pragma endregion

				/*--------------------------------------------------------------------------------
				 * Protected Methods / Event Methods
				 *------------------------------------------------------------------------------*/
				#pragma region Protected Methods / Event Methods
				/// <summary>
				///
				/// </summary>
				operator IntPtr();
				/// <summary>
				/// 
				/// </summary>
				int GetObject( int sizeofData, array<Byte^>^ storageData);
				#pragma endregion

			private:
				/*--------------------------------------------------------------------------------
				 * Private Member Declarations
				 *------------------------------------------------------------------------------*/
				#pragma region Private Member Declarations
				HGDIOBJ		_objectHandle;
				BOOL		_destroyFlag;
				#pragma endregion

			};
		}
	}
}